<template>
  <ts-table
        row-id="userId"
        :source="source"
        height="100%"
        ref="userTable"
      ></ts-table>
</template>

<script>
//防止重复提交的指令
export default {
  name: 'biSave',
  props: {},
  data() {
    return { source: this.userSourceFn() }
  },
  computed: {},
  created() {},
  mounted() {},
  methods: {
      // 用户列表配置
    userSourceFn() {
      return {
        checkbox: true,
        rownumbers: true,
        url: '/ts-system/api/role/tree',
        method: 'get',
        colModel: this.userColFn(),
        showOverflow: true,
        timeout: 20000, // 指定请求超时的毫秒数
        postData: {}
      }
    },

    userColFn() {
      return [
        { title: '服务id', field: 'id', width: 80 },
        { title: 'API名称', field: 'serviceName', width: 140 },
        { title: 'API方法名', field: '', width: 80 },
        { title: '微服务名', field: 'microserviceName', width: 80 },
        { title: '请求Path', field: 'requestPath', width: 140 },
        { title: '业务域', field: 'domainName', width: 80 },
        { title: '业务子域', field: 'secondDomainName', width: 80 },
        { title: '所属应用系统', field: 'appName', width: 80 },
        {
          title: '服务分类', field: 'serviceSource', width: 80,
          align: 'center',
          type: 'html',
          formatter: function ({ cellValue, row, column }) {
            if (cellValue == '1') {
              return '业务api'
            } else if (cellValue == '2') {
              return '数据api'
            } else if (cellValue == '3') {
              return '代理api'
            } else {
              return '消息api'
            }
          }
        },
        {
          title: '服务类别', field: 'serviceType', width: 40,
          align: 'center',
          type: 'html',
          formatter: function ({ cellValue, row, column }) {
            if (cellValue == '1') {
              return '标准'
            } else if (cellValue == '2') {
              return '自定义'
            }
          }
        },
        {
          title: '服务状态',
          field: 'onlineState',
          width: 40,
          align: 'center',
          type: 'html',
          formatter: function ({ cellValue, row, column }) {
            if (cellValue == '1') {
              return '<font class="red">未上线</font>'
            } else if (cellValue == '2') {
              return '<font class="green">已上线</font>'
            } else {
              return '-'
            }
          }
        },
        {
          title: '发布状态',
          field: 'releaseState',
          width: 40,
          align: 'center',
          type: 'html',
          formatter: function ({ cellValue, row, column }) {
            if (cellValue == '1') {
              return '<font class="red">未发布</font>'
            } else if (cellValue == '2') {
              return '<font class="green">已发布</font>'
            } else {
              return '-'
            }
          }
        },
        { title: '更新人', field: 'updatedBy', width: 80 },
        { title: '更新时间', field: 'updatedTime', width: 80 },
      ]
    },
    goPage(pageNo, pageSize, $tstable) {
      this.$refs.tsTable.data = [
        { category: 'rrrr'+pageNo, thisVal: '44444' },
        { category: 'yyyyy'+pageNo, thisVal: '44444' }
      ]
    }
  },
  watch: {}
}
</script>
<style lang="less" scoped>
.bi-save-con {
  height: 100%;
  .table-con {
    height: calc(100% - 60px);
    margin-left: 110px;
  }
}
</style>
